package com.hua.yuan.live.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.hua.yuan.common.BaseHolderView;
import com.hua.yuan.live.R;
import com.hua.yuan.live.view.holder_view.HolderView_PrivateChat;
import com.hua.yuan.live.repertory.cloud_data.res.ChatMsgBean;
import java.util.ArrayList;
import java.util.List;

/**
 * 私信界面的适配器
 */
public class PrivateMsgAdapter extends RecyclerView.Adapter<PrivateMsgAdapter.ViewHolder> {


    private List<ChatMsgBean> mData;

    private Context mContext;

    public PrivateMsgAdapter(Context pContext){
        mData=new ArrayList<>();
        this.mContext=pContext;
    }

    @Override
    public PrivateMsgAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view= LayoutInflater.from(parent.getContext()).inflate(R.layout.item_msg_live_private,parent,false);
        return new ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(PrivateMsgAdapter.ViewHolder holder, int position) {
        holder.getView().bindHolder(mData, position,mContext);
    }

    @Override
    public int getItemCount() {
        return mData.size();
    }


    static class ViewHolder extends RecyclerView.ViewHolder{

        private HolderView_PrivateChat mHolderView;

        public ViewHolder(View view){
            super(view);
            mHolderView=new HolderView_PrivateChat(view,0);
        }

        public BaseHolderView getView(){
            return mHolderView;
        }
    }

    public List<ChatMsgBean> getData(){
        return mData;
    }
}
